package com.shoponline.service.impl;

import com.shoponline.dao.UserDAO;
import com.shoponline.po.User;
import com.shoponline.service.UserService;
import com.shoponline.util.Generator;

public class UserServiceImpl implements UserService{

	
	private UserDAO userDao;
	
	
	public UserDAO getUserDao() {
		return userDao;
	}

	public void setUserDao(UserDAO userDao) {
		this.userDao = userDao;
	}

	@Override
	public boolean checkUserName(String username) {
		
		return userDao.checkUserName(username);
	}

	@Override
	public boolean checkEmail(String email) {
		
		return userDao.checkEmail(email);
	}

	@Override
	public boolean save(String username, String email, String password) {
		
		String uid = Generator.idGenerator();
		java.sql.Timestamp registertime = Generator.timeSptmaGenerator();
		User user = new User();
		
		user.setUserid(uid);
		user.setUsername(username);
		user.setEmail(email);
		user.setPassword(password);
		user.setRegisttime(registertime);
		try{
			
			userDao.saveUser(user);
			return true;
		}catch(Exception e){
			
			e.printStackTrace();
			return false;
		}
		
		
		
	}
	
}
